package team.you.change.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import team.you.change.pojo.Table;
import team.you.change.util.Result;
import team.you.change.service.TableService;

import java.util.Date;

@Controller
@RequestMapping("/table")
public class TableController {
    @Autowired
    private TableService tableService;

    @RequestMapping("/getAllTables")
    @ResponseBody
    private Result getAllTables(String courseName, String realName, String roomCode, String classCode,Integer year,
                                Integer term, Integer week, String time, Integer page, Integer limit)
    {
        return tableService.getAllTables(courseName,realName,roomCode,classCode, year, term, week, time,page,limit);
    }
    @RequestMapping("/del")
    @ResponseBody
    private Result del(Integer id)
    {
        return tableService.del(id);
    }
    @RequestMapping("/delete")
    @ResponseBody
    private Result delete(Integer[] ids)
    {
        return tableService.delete(ids);
    }
    @RequestMapping("/update")
    @ResponseBody
    private Result update(Integer id,String value,String field)
    {
        return tableService.update(id,value,field);
    }
    @RequestMapping("/getChangeTables")
    @ResponseBody
    private Result getChangeTables(String courseName, String realName, String roomCode, String classCode, String year,
                                   Integer term, Date time, Integer page, Integer limit){
        return tableService.getChangeTables(courseName, realName, roomCode, classCode, year, term, time, page, limit);
    }
    @RequestMapping("/add")
    @ResponseBody
    private Result add(String userId, String classId, String roomId, String courseId, String createTime, Integer timeSlot){
        return tableService.add(userId, classId, roomId, courseId, createTime, timeSlot);
    }
    @RequestMapping("/selectSlot")
    @ResponseBody
    private Result selectSlot(String time, Table table){
        return tableService.selectSlot(time, table);
    }
}
